var t = require("../../utils/http.js"),
  e = require("../../utils/api.js"),
  a = require("../../utils/language/switchLanguage.js");
Page({
  data: {},
  onLoad: function (t) {
    this.initLanguage(),
      this.setData({
        orderNo: t.orderNo,
        merchantNo: wx.getStorageSync("merchantNo"),
      }),
      this.getOrderDetail({ orderSn: t.orderNo });
  },
  initLanguage: function () {
    var t = a.languageVersion(wx.getStorageSync("language"));
    this.setData({ _t: t, languageType: wx.getStorageSync("language") }),
      wx.setNavigationBarTitle({ title: t["订单详情"] });
  },
  getOrderDetail: function (e) {
    var a = this;
    t.getOrderDetail(e).then(function (t) {
      var e = t.data;
      a.setData({ content: e });
    });
  },
  subForm: e.throttle(function () {
    this.wechatPay();
  }),
  wechatPay: function (a) {
    var n = this,
      r = {
        merchantNo: wx.getStorageSync("merchantNo"),
        tradeType: "wxSmallPay",
        payType: 4,
        payConfigType: 4,
        orderNo: this.data.orderNo,
      },
      o = e.encryptBASE64(JSON.stringify(r)),
      i = { sign: e.autograph(o), signData: o };
    t.wechatPay(i).then(function (t) {
      requireMiniProgram()
        .requestPayment(t.data)
        .then(function (t) {
          "requestPayment:ok" == t.errMsg &&
            (wx.showLoading({ title: n.data._t["支付处理中"] + "..." }),
            setTimeout(function () {
              wx.hideLoading();
              var t = getCurrentPages(),
                e = t[t.length - 2];
              e.setData({ refresh: !0 }, function () {
                var t = e.data.params;
                (t.page = 1), e.getOrderList(t);
              }),
                wx.navigateBack();
            }, 1e3));
        })
        .catch(function (t) {
          "requestPayment:fail cancel" != t.errMsg &&
            "requestPayment:fail" != t.errMsg &&
            wx.showModal({
              title: n.data._t["通知"],
              showCancel: !1,
              content: n.data._t["调起支付失败，请稍后重试"] + "...",
              confirmText: n.data._t["确认"],
            });
        });
    });
  },
  CancelOrder: function (t) {
    wx.navigateTo({
      url: "plugin-private://wx393d60d93f70599c/pages/teamCancel-order/index?orderSn=".concat(
        this.data.content.orderSn,
      ),
    });
  },
  toPage: function () {
    wx.navigateTo({
      url:
        "plugin-private://wx393d60d93f70599c/pages/Rule/index?orderType=" +
        this.data.content.orderType +
        "&teamType=" +
        this.data.content.teamType,
    });
  },
  CallPhone: function () {
    wx.makePhoneCall({ phoneNumber: wx.getStorageSync("telphoneNumber") });
  },
  onReady: function () {},
  onShow: function () {},
  onHide: function () {},
  onUnload: function () {},
  onPullDownRefresh: function () {},
  onReachBottom: function () {},
});
